package com.coolingme.demo.aspect;

import lombok.extern.slf4j.Slf4j;

/**
 * 切面类
 *
 * @author wangyue
 * @date 2024/09/09 21:52
 */
@Slf4j
public class LogAspect {

    // -------------------------------------v2----------------------------------------


    //在调用一个方法之前，执行before方法
//    public void before(MeJoinPoint joinPoint){
//        joinPoint.setUserAttribute("startTime_" + joinPoint.getMethod().getName(),System.currentTimeMillis());
//        //这个方法中的逻辑，是由我们自己写的
//        log.info("Invoker Before Method!!!");
//    }
//    //在调用一个方法之后，执行after方法
//    public void after(MeJoinPoint joinPoint){
//        long startTime = (Long)joinPoint.getUserAttribute("startTime_" + joinPoint.getMethod().getName());
//        long endTime = System.currentTimeMillis();
//        log.info("Invoker After Method!!!" + "use time :" + (endTime - startTime));
//    }
//
//    public void afterThrowing(MeJoinPoint joinPoint,Throwable tx){
//
//        log.info("出现异常");
//    }

    // -------------------------------------v1----------------------------------------

    public void before() {
        log.info("Invoker Before Method!!!");
    }

    public void after() {
        log.info("Invoker After Method!!!");
    }

    public void afterThrowing() {
        log.info("出现异常");
    }


}
